<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .parent{
            display: flex;
        }
        .child{
            width:200px;
            height: 60px;
            background:url(images/green.png) no-repeat;
            margin-right: 1px;
            text-align: center;
            line-height: 60px;
            color:gray;
        }
        .over{
            background:url(images/blue.png) no-repeat;
            color:white;
        }
        .out{
            background:url(images/green.png) no-repeat;
            color:gray;
        }
    </style>
    <script>    
        function doOver(obj){
        //    obj.style.backgroundImage="url(images/blue.png)";
           // obj.style.color="white";
           obj.classList.add("over");
           obj.classList.remove("out");
        }
        function doOut(obj){
            // console.log(obj);
            // obj.style.backgroundImage="url(images/green.png)";
            // obj.style.color="gray";
            obj.classList.remove("over");
            obj.classList.add("out");
        }
    </script>
</head>

<body>
    <div class="parent">

        <!-- this表示的是触发事件的元素，也称为事件源 -->
        <div class="child" onmouseover="doOver(this)" onmouseout="doOut(this)">南京</div>
        <div class="child" onmouseover="doOver(this)" onmouseout="doOut(this)">上海</div>
        <div class="child" onmouseover="doOver(this)" onmouseout="doOut(this)">北京</div>
    </div>
</body>

</html>